package com.cadre.common.utils.oldutil;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/* loaded from: JianLiFormat.class */
public class JianLiFormat {
    private String indentSpace = "                  ";
    private List<String> lineList = new ArrayList();
    private List<JianLiData> sizeRules = JianLiData.getInstance();

    public JianLiData processJianLi(String jianli) {
        if (jianli == null || "".equals(jianli)) {
            return this.sizeRules.get(0);
        }
        String[] lines = jianli.split("\\r?\\n");
        for (JianLiData rule : this.sizeRules) {
            this.lineList.clear();
            for (String line : lines) {
                subLine(line, rule.getWordsNumPerLine());
            }
            if (rule.getLineNum() >= this.lineList.size()) {
                rule.setJianli((String) this.lineList.stream().collect(Collectors.joining("\n")));
                return rule;
            }
        }
        JianLiData rule2 = this.sizeRules.get(this.sizeRules.size() - 1);
        rule2.setJianli((String) this.lineList.stream().collect(Collectors.joining("\n")));
        return rule2;
    }

    public void subLine(String line, int numPerLine) {
        String line2 = JianLiStringUtils.rtrim(line);
        if (JianLiStringUtils.getWordCount(line2) <= numPerLine * 2) {
            this.lineList.add(line2);
            return;
        }
        String childString = JianLiStringUtils.dateProcessing(JianLiStringUtils.byteSubString(line2, numPerLine));
        this.lineList.add(childString);
        subLine(this.indentSpace + line2.substring(childString.length()), numPerLine);
    }
}
